﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Pragma" contect="no-cache" />
    <title></title>

    <link href="../source/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
    <link href="../source/css/bootstrap-select.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../source/zTree/v3/css/zTreeStyle/zTreeStyle.css">
    <script src="../source/js/common_url.js"></script>
    <script src="../source/js/util.js"></script>
    <script src="../nurse_mgr/js/common_data.js"></script>
    <script src="../source/js/jquery-1.9.1.min.js"></script>
    <script src="../source/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
    <script src="../source/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="../source/js/bootstrap-select.min.js"></script>
    <script src="../source/layer/layer.js"></script>
    <style>
        .ztree li span.button.ico_docu{
            display: none;
        }
        .searchbar{
            position: relative;
        }
        .searchbar .res{
            position: absolute;
            left: 0;
            right: 0;
            display: none;
            max-height: 200px;
            background: #fff;
            padding:5px;
            border-radius: 2px;
            overflow-y: auto;
            z-index: 9999;
        }
        .res ul{
            box-shadow: 0 0 4px 0 #000;
        }
        .searchbar input{
            outline: none;
            border: 1px solid #ccc;
            line-height: 35px;
            border-radius: 2px;
            padding: 0 5px;
            width: 100%;
        }
        ul,li{
            font-style: normal;
            list-style: none;
            padding: 0;
        }
        .searchbar .res li{
            line-height: 35px;
            padding: 0 10px;
            border-bottom: 1px dashed #ccc;
            cursor: pointer;
        }
        #c-1 {
            line-height: 45px;
        }
        ::-webkit-scrollbar {/*滚动条整体样式*/
            width: 5px;     /*高宽分别对应横竖滚动条的尺寸*/
            height: 5px;
        }

        ::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
            border-radius: 2px;
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            background: #535353;
        }

        ::-webkit-scrollbar-track {/*滚动条里面轨道*/
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            border-radius: 2px;
            background: none;
        }
        ::-webkit-scrollbar-thumb:vertical {
            height: 5px;
            background-color: #1AACFF;
        }

        ::-webkit-scrollbar-thumb:horizontal {
            width: 5px;
            background-color: #1AACFF;
        }
        .body_content{
            width: 90%;
            margin: 0 auto;
        }
        .ztrees{
            height: 320px;
            overflow-y: auto;
        }
        .ztree li span.button.switch{
            height: 24px;
        }
        .ztree li a,
        .ztree li a.curSelectedNode,
        .ztree li span{
            line-height: 24px;
            height: 24px;
        }
        .ztree li span:last-child{
            display: inline-block;
            max-width: 18em;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .ztree *{
            font-size: 14px;
        }
        .ztree li span.button.noline_close{
            background: url("../source/img/icon/icon-close.png")  no-repeat center;
        }
        .ztree li span.button.noline_open{
            background: url("../source/img/icon/icon-open.png") no-repeat center;
        }
    </style>

</head>
<body>
    <div class="body">
        <div class="body_content">
            <div id="c-1">请选择分诊队列:</div>
            <div class="searchbar">
                <input type="text" id="kw" placeholder="请输入队列名称">
                <div id="result" class="res">
                    <ul></ul>
                </div>
            </div>
            <div class="ztrees">
                <ul id="treeDemo" class="ztree"></ul>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var _ids = "";
    var _queueId = "";
    var _queueKey = "";
    var _systemId = "";
    var curr = {};
    var nodeArr = [];
    var res = {"status":0,"desc":"操作成功","data":[{"missPenalty":0,"deptName":"jyx","autoOverFlowTime":5,"outpatientPlayRule":"{\"isWaitingAreaPlay\":1,\"isWaitingAreaShow\":1,\"isOutpatientAreaPlay\":1,\"isOutpatientAreaShow\":1}","editTime":"20210903084739","reportPeriod":1,"homeWaiting":1,"systemName":"jyx分诊叫号子系统","signType":1,"isCreateWindowNo":0,"addressConfig":null,"waitCallingNum":0,"triageType":2,"overFlowRecallCount":1,"hasCallingMachine":1,"isParent":"true","outpatientAreaPlayCount":1,"deptId":"d2fca0276eb14b29af8a9fdfb3cae4c3","isIntraday":1,"returnVisitTerm":1,"hasQueue":1,"systemConfig":"{\"patientShow\": {\"am\": \"0\", \"pm\": \"0\", \"type\": 0}}","waitingAreaPlayCount":1,"isManually":0,"clinicNameCallingWay":1,"advanceSignTime":5,"waitingPlayRule":"{\"isWaitingAreaPlay\":1,\"isWaitingAreaShow\":1,\"isOutpatientAreaPlay\":1,\"isOutpatientAreaShow\":1}","registerCallingWay":2,"systemModel":0,"qcQueueList":[{"queueId":"572bd07b57de4b85956ec26b73bd6a47","queueKey":"800694ed1d35421b95518d4044c019c1_3","queueName":"专家队列","showName":"","relationType":2,"queueStatus":2,"queueType":1,"editor":"800694ed1d35421b95518d4044c019c1","editTime":"20210918173834","isDeleted":0,"deptId":"d2fca0276eb14b29af8a9fdfb3cae4c3","deptName":"jyx","systemId":"27563076b77a4b2ca30aabd1ca6cf459","isTempQueue":null,"creatTime":"20210713000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"6ecd7fa24c9248f3b61483a5502f6b56","queueKey":"15756bc8fca84db7ae1e67914236f8a0_3","queueName":"程小东专家队列","showName":"","relationType":2,"queueStatus":2,"queueType":1,"editor":"f7f106d06802492d961d9dc289bd64b3","editTime":"20210713095415","isDeleted":0,"deptId":"d2fca0276eb14b29af8a9fdfb3cae4c3","deptName":"jyx","systemId":"27563076b77a4b2ca30aabd1ca6cf459","isTempQueue":null,"creatTime":"20210713000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"c29537866940463e8bab282c46d1327d","queueKey":"d2fca0276eb14b29af8a9fdfb3cae4c3_3","queueName":"河北四院测试普通队列","showName":"","relationType":1,"queueStatus":2,"queueType":1,"editor":"47d18e2aab19420096eedb44b491aa8a","editTime":"20210903153534","isDeleted":0,"deptId":"d2fca0276eb14b29af8a9fdfb3cae4c3","deptName":"jyx","systemId":"27563076b77a4b2ca30aabd1ca6cf459","isTempQueue":null,"creatTime":"20210721000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"43e99f2c129d4b05bf252006273af498","queueKey":"d2fca0276eb14b29af8a9fdfb3cae4c3_4","queueName":"宿迁张三普通队列","showName":"","relationType":1,"queueStatus":2,"queueType":1,"editor":"f7f106d06802492d961d9dc289bd64b3","editTime":"20210902154546","isDeleted":0,"deptId":"d2fca0276eb14b29af8a9fdfb3cae4c3","deptName":"jyx","systemId":"27563076b77a4b2ca30aabd1ca6cf459","isTempQueue":null,"creatTime":"20210728000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"cdc66fbdda3549c2926828620b58b846","queueKey":"d2fca0276eb14b29af8a9fdfb3cae4c3_5","queueName":"李四普通队列","showName":"","relationType":1,"queueStatus":2,"queueType":1,"editor":"bc72237fbe8c454abe0545c44b7b6bb0","editTime":"20210728202016","isDeleted":0,"deptId":"d2fca0276eb14b29af8a9fdfb3cae4c3","deptName":"jyx","systemId":"27563076b77a4b2ca30aabd1ca6cf459","isTempQueue":null,"creatTime":"20210728000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0}],"signDelayMinute":0,"queuingOrderNoType":"YM-801","greenChannel":1,"delayedTriageType":0,"hasWindowNo":1,"isPretest":0,"priorAge":null,"waitingNum":2,"isDeleted":0,"hospitalId":"4e66fabafd944e458dc259ce890c31f3","systemType":1,"overFlowRecallType":1,"editor":"f7f106d06802492d961d9dc289bd64b3","systemId":"27563076b77a4b2ca30aabd1ca6cf459","callingServerSource":"YM-801","queuingOrderType":1,"isNameProtect":0,"returnVisitNum":1,"hasDispenseMachine":0,"waitingPlayContent":"请\"就诊号\"\"患者\"到\"诊室\"门口候诊进行等候","playType":0,"voiceConfig":"{\"PromptingMode\":\"1\",\"SpeedTone\":\"60\",\"VoiceType\":\"2\",\"Language\":\"2\",\"PlayBookWords\":false}","systemStatus":1,"outpatientPlayContent":"[{\"order\":1,\"type\":\"text\",\"content\":\"请\"},{\"order\":2,\"type\":\"registerId\",\"content\":\"就诊号\"},{\"order\":3,\"type\":\"patientName\",\"content\":\"患者\"},{\"order\":4,\"type\":\"text\",\"content\":\"到\"},{\"order\":5,\"type\":\"dept\",\"content\":\"终端科室\"},{\"order\":6,\"type\":\"clinic\",\"content\":\"诊室\"},{\"order\":7,\"type\":\"text\",\"content\":\"就诊\"}]","nameProtectType":2},{"missPenalty":0,"deptName":"A临床","autoOverFlowTime":5,"outpatientPlayRule":"{\"isWaitingAreaPlay\":\"1\",\"isWaitingAreaShow\":\"1\",\"isOutpatientAreaPlay\":\"1\",\"isOutpatientAreaShow\":\"1\"}","editTime":"20210916161850","reportPeriod":1,"homeWaiting":1,"systemName":"A临床分诊叫号子系统","signType":2,"isCreateWindowNo":0,"addressConfig":null,"waitCallingNum":0,"triageType":2,"overFlowRecallCount":1,"hasCallingMachine":1,"isParent":"true","outpatientAreaPlayCount":1,"deptId":"d28a07d321ff444f902c72340caa00a9","isIntraday":1,"returnVisitTerm":1,"hasQueue":1,"systemConfig":"{\"patientShow\": {\"am\": \"0\", \"pm\": \"0\", \"type\": 0}}","waitingAreaPlayCount":1,"isManually":0,"clinicNameCallingWay":1,"advanceSignTime":5,"waitingPlayRule":"{\"isWaitingAreaPlay\":\"1\",\"isWaitingAreaShow\":\"1\",\"isOutpatientAreaPlay\":\"1\",\"isOutpatientAreaShow\":\"1\"}","registerCallingWay":2,"systemModel":0,"qcQueueList":[{"queueId":"711fbc6043fd4b39b7c4c9aecd26838c","queueKey":"31138b8b792343c2ac4a572fc30f04a5_1","queueName":"临床-钟-专家队列","showName":"","relationType":2,"queueStatus":2,"queueType":1,"editor":"31138b8b792343c2ac4a572fc30f04a5","editTime":"20210918174552","isDeleted":0,"deptId":"d28a07d321ff444f902c72340caa00a9","deptName":"A临床","systemId":"6c063008e3fc492491054ccf0f973eaa","isTempQueue":null,"creatTime":"20210908000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"df9ebfca07a24d0dace6beccddce6f64","queueKey":"d28a07d321ff444f902c72340caa00a9_1","queueName":"普通队列","showName":"","relationType":1,"queueStatus":2,"queueType":1,"editor":"80ca4d682bf4476e850e90541579f577","editTime":"20210918170900","isDeleted":0,"deptId":"d28a07d321ff444f902c72340caa00a9","deptName":"A临床","systemId":"6c063008e3fc492491054ccf0f973eaa","isTempQueue":null,"creatTime":"20210908000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0}],"signDelayMinute":0,"queuingOrderNoType":"YM-801","greenChannel":1,"delayedTriageType":0,"hasWindowNo":1,"isPretest":0,"priorAge":null,"waitingNum":5,"isDeleted":0,"hospitalId":"4e66fabafd944e458dc259ce890c31f3","systemType":1,"overFlowRecallType":1,"editor":"f7f106d06802492d961d9dc289bd64b1","systemId":"6c063008e3fc492491054ccf0f973eaa","callingServerSource":"YM-801","queuingOrderType":1,"isNameProtect":1,"returnVisitNum":1,"hasDispenseMachine":0,"waitingPlayContent":"请\"就诊号\"\"患者\"到\"诊室\"门口候诊","playType":0,"voiceConfig":"{\"PromptingMode\":\"1\",\"SpeedTone\":\"60\",\"VoiceType\":\"2\",\"Language\":\"2\",\"PlayBookWords\":false}","systemStatus":1,"outpatientPlayContent":"[{\"order\":1,\"type\":\"text\",\"content\":\"请\"},{\"order\":2,\"type\":\"registerId\",\"content\":\"就诊号\"},{\"order\":3,\"type\":\"patientName\",\"content\":\"患者\"},{\"order\":4,\"type\":\"text\",\"content\":\"到\"},{\"order\":5,\"type\":\"dept\",\"content\":\"终端科室\"},{\"order\":6,\"type\":\"clinic\",\"content\":\"诊室\"},{\"order\":7,\"type\":\"text\",\"content\":\"就诊\"}]","nameProtectType":2},{"missPenalty":0,"deptName":"A临床","autoOverFlowTime":5,"outpatientPlayRule":"{\"isWaitingAreaPlay\":\"1\",\"isWaitingAreaShow\":\"1\",\"isOutpatientAreaPlay\":\"1\",\"isOutpatientAreaShow\":\"1\"}","editTime":"20210928111854","reportPeriod":1,"homeWaiting":1,"systemName":"A临床分诊叫号子系统-1","signType":2,"isCreateWindowNo":0,"addressConfig":null,"waitCallingNum":0,"triageType":2,"overFlowRecallCount":1,"hasCallingMachine":1,"isParent":"true","outpatientAreaPlayCount":1,"deptId":"d28a07d321ff444f902c72340caa00a9","isIntraday":1,"returnVisitTerm":1,"hasQueue":1,"systemConfig":"{\"patientShow\": {\"am\": \"0\", \"pm\": \"0\", \"type\": 0}}","waitingAreaPlayCount":1,"isManually":0,"clinicNameCallingWay":1,"advanceSignTime":5,"waitingPlayRule":"{\"isWaitingAreaPlay\":\"1\",\"isWaitingAreaShow\":\"1\",\"isOutpatientAreaPlay\":\"1\",\"isOutpatientAreaShow\":\"1\"}","registerCallingWay":2,"systemModel":0,"qcQueueList":[{"queueId":"159ef1cc22074e578afdae30546f2bbd","queueKey":"99327eea74284b62aa3ddee2265d3332_1","queueName":"专家队列","showName":"","relationType":2,"queueStatus":2,"queueType":1,"editor":"f7f106d06802492d961d9dc289bd64b1","editTime":"20210928111931","isDeleted":0,"deptId":"d28a07d321ff444f902c72340caa00a9","deptName":"A临床","systemId":"9626693bdfcf40e6913267bdd9e5f8ba","isTempQueue":null,"creatTime":"20210928000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0}],"signDelayMinute":0,"queuingOrderNoType":"YM-801","greenChannel":1,"delayedTriageType":1,"hasWindowNo":1,"isPretest":0,"priorAge":null,"waitingNum":2,"isDeleted":0,"hospitalId":"4e66fabafd944e458dc259ce890c31f3","systemType":1,"overFlowRecallType":1,"editor":"f7f106d06802492d961d9dc289bd64b1","systemId":"9626693bdfcf40e6913267bdd9e5f8ba","callingServerSource":"YM-801","queuingOrderType":1,"isNameProtect":0,"returnVisitNum":1,"hasDispenseMachine":0,"waitingPlayContent":"请\"就诊号\"\"患者\"到\"诊室\"门口候诊","playType":0,"voiceConfig":"{\"PromptingMode\":\"1\",\"SpeedTone\":\"60\",\"VoiceType\":\"2\",\"Language\":\"2\",\"PlayBookWords\":false}","systemStatus":1,"outpatientPlayContent":"[{\"order\":1,\"type\":\"text\",\"content\":\"请\"},{\"order\":2,\"type\":\"registerId\",\"content\":\"就诊号\"},{\"order\":3,\"type\":\"patientName\",\"content\":\"患者\"},{\"order\":4,\"type\":\"text\",\"content\":\"到\"},{\"order\":5,\"type\":\"dept\",\"content\":\"终端科室\"},{\"order\":6,\"type\":\"clinic\",\"content\":\"诊室\"},{\"order\":7,\"type\":\"text\",\"content\":\"就诊\"}]","nameProtectType":2},{"missPenalty":0,"deptName":"河北四院","autoOverFlowTime":5,"outpatientPlayRule":"{\"isWaitingAreaPlay\":1,\"isWaitingAreaShow\":1,\"isOutpatientAreaPlay\":\"1\",\"isOutpatientAreaShow\":\"1\"}","editTime":"20210902162642","reportPeriod":1,"homeWaiting":1,"systemName":"河北四院分诊叫号子系统","signType":2,"isCreateWindowNo":0,"addressConfig":null,"waitCallingNum":0,"triageType":2,"overFlowRecallCount":1,"hasCallingMachine":1,"isParent":"true","outpatientAreaPlayCount":1,"deptId":"a4ebe1559e464543b0c03be36f4ef8ce","isIntraday":1,"returnVisitTerm":1,"hasQueue":1,"systemConfig":"{\"patientShow\": {\"am\": \"0\", \"pm\": \"0\", \"type\": 0}}","waitingAreaPlayCount":1,"isManually":0,"clinicNameCallingWay":1,"advanceSignTime":5,"waitingPlayRule":"{\"isWaitingAreaPlay\":1,\"isWaitingAreaShow\":1,\"isOutpatientAreaPlay\":\"1\",\"isOutpatientAreaShow\":\"1\"}","registerCallingWay":2,"systemModel":0,"qcQueueList":[{"queueId":"70f474924e664e6f81acff85a4f743b3","queueKey":"c758e325eaf74ea2bb144977fd65f686_1","queueName":"吴医生-专家队列","showName":"","relationType":2,"queueStatus":2,"queueType":1,"editor":"c758e325eaf74ea2bb144977fd65f686","editTime":"20210721133120","isDeleted":0,"deptId":"a4ebe1559e464543b0c03be36f4ef8ce","deptName":"河北四院","systemId":"dd0db9ea8c7b4576b8a65cc90a5aac64","isTempQueue":null,"creatTime":"20210716000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"95802291f31146959960395ad99793ad","queueKey":"c758e325eaf74ea2bb144977fd65f686_2","queueName":"吴医生-专家队列1","showName":"","relationType":2,"queueStatus":2,"queueType":1,"editor":"c758e325eaf74ea2bb144977fd65f686","editTime":"20210730082214","isDeleted":0,"deptId":"a4ebe1559e464543b0c03be36f4ef8ce","deptName":"河北四院","systemId":"dd0db9ea8c7b4576b8a65cc90a5aac64","isTempQueue":null,"creatTime":"20210717000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"03c254f6b7684dc98efcb72d3db7a98d","queueKey":"a4ebe1559e464543b0c03be36f4ef8ce_1","queueName":"四院测试","showName":"","relationType":1,"queueStatus":2,"queueType":1,"editor":"c758e325eaf74ea2bb144977fd65f686","editTime":"20210722145330","isDeleted":0,"deptId":"a4ebe1559e464543b0c03be36f4ef8ce","deptName":"河北四院","systemId":"dd0db9ea8c7b4576b8a65cc90a5aac64","isTempQueue":null,"creatTime":"20210721000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0},{"queueId":"e935a2ccb0d54619bedbe7526fd50051","queueKey":"a4ebe1559e464543b0c03be36f4ef8ce_2","queueName":"普通队列","showName":"","relationType":1,"queueStatus":2,"queueType":1,"editor":"f7f106d06802492d961d9dc289bd64b1","editTime":"20210828110201","isDeleted":0,"deptId":"a4ebe1559e464543b0c03be36f4ef8ce","deptName":"河北四院","systemId":"dd0db9ea8c7b4576b8a65cc90a5aac64","isTempQueue":null,"creatTime":"20210828000000","hospitalId":"4e66fabafd944e458dc259ce890c31f3","queuePrefix":"","queueSuffix":"","sort":0,"isSort":0}],"signDelayMinute":0,"queuingOrderNoType":"YM-801","greenChannel":1,"delayedTriageType":0,"hasWindowNo":1,"isPretest":0,"priorAge":null,"waitingNum":2,"isDeleted":0,"hospitalId":"4e66fabafd944e458dc259ce890c31f3","systemType":1,"overFlowRecallType":1,"editor":"f7f106d06802492d961d9dc289bd64b1","systemId":"dd0db9ea8c7b4576b8a65cc90a5aac64","callingServerSource":"YM-801","queuingOrderType":1,"isNameProtect":0,"returnVisitNum":1,"hasDispenseMachine":0,"waitingPlayContent":"请\"就诊号\"\"患者\"到\"诊室\"门口候诊","playType":0,"voiceConfig":"{\"PromptingMode\":\"1\",\"SpeedTone\":\"60\",\"VoiceType\":\"2\",\"Language\":\"2\",\"PlayBookWords\":false}","systemStatus":1,"outpatientPlayContent":"[{\"order\":1,\"type\":\"text\",\"content\":\"请\"},{\"order\":2,\"type\":\"registerId\",\"content\":\"就诊号\"},{\"order\":3,\"type\":\"patientName\",\"content\":\"患者\"},{\"order\":4,\"type\":\"text\",\"content\":\"到\"},{\"order\":5,\"type\":\"dept\",\"content\":\"终端科室\"},{\"order\":6,\"type\":\"clinic\",\"content\":\"诊室\"},{\"order\":7,\"type\":\"text\",\"content\":\"就诊\"}]","nameProtectType":2}]};
    $(function () {
        // 加载下拉框
        _ids = GetQueryString("ids");
        _queueId = GetQueryString("queueId");
        _queueKey = GetQueryString("queueKey");
        _systemId = GetQueryString("systemId");
        $('#kw').on('input propertychange',function () {
            var k = $(this).val();
            if(k!=''){
                var frag = '';
                var reg = eval("/^.*?"+k+".*?$/");
                for (var i=0;i<nodeArr.length;i++){
                    if(!nodeArr[i]||nodeArr[i]=='') continue;
                    if(reg.test(nodeArr[i]['name'])){
                        frag +='<li data-eid="'+nodeArr[i]['id']+'" data-qid="'+nodeArr[i]['queueKey']+'">'+nodeArr[i]['name']+'</li>';
                    }
                }
                $('#result').show().find('ul').html(frag);
            }else {
                $('#result').hide().find('ul').html('');
            }
        });
        $('#result').on('click','li',function () {
            var eid = $(this).data('eid');
            var qid = $(this).data('qid');
            curr.id = eid;
            curr.queueKey = qid;
            curr.isQueue = true;
            var ztree = $.fn.zTree.getZTreeObj("treeDemo");
            var node = ztree.getNodeByParam("id", eid);
            ztree.cancelSelectedNode();//先取消所有的选中状态
            ztree.selectNode(node, true);//将指定ID的节点选中
            ztree.expandNode(node, true, false);//将指定ID节点展开
            $('#result').hide().find('ul').html('');
        });

        var hospitalId = getHospitalId();
        $.ajax({
            url: _getTransferQueueIds,
            type: "get",
            data: {
                hospitalId: hospitalId,
                queueId: _queueId,
                systemId: _systemId
            },
            beforeSend: function () {
                layer.msg("加载中", { icon: 16 });
            },
            success: function (data) {
                layer.closeAll();
                var result = JSON.parse(data);
                if (result.status == 0) {
                    dealResData(result.data)
                } else {
                    layer.alert(result.desc, { icon: 2 });
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log(textStatus);
                console.log(errorThrown);
                layer.alert("操作失败!", { icon: 2 });
            }
        });
    });

    function setTransferQueue(callback) {
        if(!curr.isQueue) return layer.msg('请选择转诊队列！',{icon:0});
        var queueId = curr.id||'';
        var queueKey = curr.queueKey||'';
        var loginId = getLoginUserId();
        // 发送ajax请求转载
        $.ajax({
            url: _transferPatients,
            type: "post",
            async: false,
            data: {
                id: _ids,
                queueId: queueId,
                queueKey: queueKey,
                loginId: loginId
            },
            success: function (data) {
                var result = JSON.parse(data);
                callback&&callback(result)
            },
            error: function (jqXHR, textStatus, errorThrown) {
                callback&&callback( {status:0,desc:'操作失败!'})
            }
        });
    };
    function dealResData(arr) {
        var nodes = {};
        arr = arr ||[];
        for (var i =0;i<arr.length;i++){
            if(!arr[i]||arr[i]=='') continue;
            // 处理科室 防止重复
            if(!nodes[arr[i]['deptId']]){
                nodes[arr[i]['deptId']] = {
                    name:arr[i]['deptName'],
                    pId:0,
                    id:arr[i]['deptId'],
                    open:true,
                    isQueue:false,
                    isParent:true
                };
            }
            // 处理子系统
            nodes[arr[i]['systemId']] = {
                name:arr[i]['systemName'],
                pId:arr[i]['deptId'],
                id:arr[i]['systemId'],
                open:false,
                isQueue:false,
                isParent:true
            };
            nodeArr = nodeArr.concat(dealQueue(arr[i]['systemId'],arr[i]['qcQueueList']));
        }

        for (var k in nodes){
            nodeArr.push(nodes[k]);
        }
        var setting = {
            view: {
                showLine: false,
                showIcon: showIconForTree
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                onClick: onClick
            }
        };
        $.fn.zTree.init($("#treeDemo"), setting, nodeArr);
    }
    function onClick(event, treeId, treeNode, clickFlag) {
        curr = treeNode;
    }
    function showIconForTree(treeId, treeNode) {
        return !treeNode.isParent;
    };
    function dealQueue(pid,arr) {
        pid = pid || '';
        arr = arr ||[];
        var resArr = [] ;
        for (var i = 0;i<arr.length;i++){
            if(!arr[i]||arr[i]=='') continue;
            resArr.push({
                name:arr[i]['queueName'],
                pId:pid,
                isQueue:true,
                id:arr[i]['queueId'],
                queueKey:arr[i]['queueKey'],
                isParent:false
            })
        }
        return resArr;
    }
</script>
